//
//  TitleButton.swift
//  weibo
//
//  Created by 叶子韬韬 on 2017/4/21.
//  Copyright © 2017年 叶子韬韬. All rights reserved.
//

import UIKit

class TitleButton: UIButton {

    // MARK:- #注释>重写init
    override init(frame: CGRect) {
        super .init(frame:frame)
        
        setImage(UIImage(named:"navigationbar_arrow_down"), for: .normal)
        setImage(UIImage(named:"navigationbar_arrow_up"), for: .selected)
        
        setTitleColor(UIColor.black, for: .normal)
        sizeToFit()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        // MARK:- #注释> 重新修改titleLabel的x坐标
        titleLabel!.frame.origin.x = 0
        // MARK:- #注释> 重新修改imageView的x坐标
        imageView!.frame.origin.x = titleLabel!.frame.size.width + 5
        
    }
}
